Promise.all = function (promises) {
    return new Promise((resolve, reject) => {
        if (Array.isArray(promises)) {
            let result = []
            let count = 0
            if (promises.length === 0) {
                return resolve(promises)
            }
            promises.forEach((item, index) => {
                Promise.resolve(item).then(
                    (value) => {
                        count++
                        result[index] = value
                        count === promises.length && resolve(result);
                    },
                    (reason) => {
                        reject(reason)
                    }
                )
            })
        } else {
            return reject(new TypeError('Argument is not iterable'))
        }
    })
}